home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / net / sun4.md / netIEInt.h < prev    next >
C/C++ Source or Header  |  1990-11-29  |  30KB  |  853 lines

  1. /*
  2.  * netIEInt.h --
  3.  *
  4.  *    External definitions for the Intel on-board Ethernet controller.  See
  5.  *      the Intel "LAN Components User's Manual" from 1984 for a 
  6.  *    description of the definitions here.  One note is that the Intel chip 
  7.  *    is wired in byte swapped order.  Therefore all definitions in here are 
  8.  *    byte swapped from the ones in the user's manual.
  9.  *
  10.  * Copyright 1985, 1988 Regents of the University of California
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  *
  19.  *
  20.  * $Header: /sprite/src/kernel/net/sun3.md/RCS/netIEInt.h,v 9.5 90/11/29 15:46:55 shirriff Exp $ SPRITE (Berkeley)
  21.  */
  22.  
  23. #ifndef _NETIEINT
  24. #define _NETIEINT
  25.  
  26. #include <netInt.h>
  27.  
  28. /*
  29.  * Defined constants:
  30.  *
  31.  * NET_IE_CONTROL_REG_ADDR    The address of the control register for the 
  32.  *                ethernet chip.
  33.  * NET_IE_SYS_CONF_PTR_ADDR     Place where the system configuration pointer 
  34.  *                must start. 
  35.  * NET_IE_DELAY_CONST        Number of loops to poll the ethernet chip
  36.  *                before giving up. (see NET_IE_DELAY())
  37.  * NET_IE_CHUNK_SIZE        The number of bytes that memory is allocated
  38.  *                in.
  39.  * NET_IE_MEM_SIZE              Amount of memory to set aside for the control 
  40.  *                blocks.
  41.  * NET_IE_NUM_RECV_BUFFERS      The number of buffers that we have to receive
  42.  *                   packets in.
  43.  * NET_IE_NUM_XMIT_BUFFERS      The number of buffer descriptors that are used
  44.  *                   for a transmitted packet.
  45.  * NET_IE_RECV_BUFFER_SIZE      The size of each receive buffer.
  46.  * NET_IE_MIN_DMA_SIZE        The smallest buffer that can be use for DMA.
  47.  *                If a piece of a message is smaller than this
  48.  *                then it gets copied to other storage and
  49.  *                made the minimum size.
  50.  * NET_IE_NULL_RECV_BUFF_DESC     The value that is used by the controller to 
  51.  *                indicate that a header points to no data.
  52.  * NET_IE_NUM_XMIT_ELEMENTS     The number of elements to preallocate for the 
  53.  *                   retransmission queue.
  54.  */
  55.  
  56. #ifdef sun3
  57. #define NET_IE_CONTROL_REG_ADDR        0xfe0c000
  58. #define NET_IE_SYS_CONF_PTR_ADDR    0xffffff6
  59. #define    NET_IE_DELAY_CONST        400000
  60. #endif /* sun3 */
  61.  
  62.  
  63. #ifdef sun2
  64. #define NET_IE_CONTROL_REG_ADDR        0xee3000
  65. #define NET_IE_SYS_CONF_PTR_ADDR    0xfffff6
  66. #define    NET_IE_DELAY_CONST        (400000>>2)
  67. #endif /* sun2 */
  68.  
  69. #ifdef sun4
  70. #define NET_IE_CONTROL_REG_ADDR        0xffd0c000
  71. #define NET_IE_SYS_CONF_PTR_ADDR    0xfffffff4
  72. #define    NET_IE_DELAY_CONST        (400000<<2)
  73. #endif /* sun4 */
  74.  
  75. #define    NET_IE_CHUNK_SIZE        32
  76. #define    NET_IE_MEM_SIZE            2048
  77. #define    NET_IE_NUM_RECV_BUFFERS        18
  78. #define    NET_IE_NUM_XMIT_BUFFERS        20
  79. #define    NET_IE_RECV_BUFFER_SIZE        NET_ETHER_MAX_BYTES
  80. #define    NET_IE_MIN_DMA_SIZE        12
  81. #define    NET_IE_NULL_RECV_BUFF_DESC    0xffff
  82. #define    NET_IE_NUM_XMIT_ELEMENTS    32
  83.  
  84. /*
  85.  * Macros to manipulate the chip.
  86.  *
  87.  * NET_IE_CHIP_RESET        Reset the chip.
  88.  * NET_IE_CHANNEL_ATTENTION    Get the attention of the chip.
  89.  * NET_IE_DELAY            Delay until the microsecond limit is up or
  90.  *                until the condition is true.
  91.  * NET_IE_CHECK_SCB_CMD_ACCEPT    Check to see if the command has been accepted.
  92.  * NET_IE_ADDR_FROM_SUN_ADDR    Change a SUN address to an intel address.
  93.  * NET_IE_ADDR_TO_SUN_ADDR    Change an intel address to a SUN address.
  94.  */
  95.  
  96. #define NET_IE_CHIP_RESET(statePtr) \
  97.     (*(volatile char *) statePtr->controlReg = 0)
  98. #define NET_IE_CHANNEL_ATTENTION(statePtr) \
  99.     { \
  100.         NetBfByteSet(statePtr->controlReg, ChannelAttn, 1); \
  101.         NetBfByteSet(statePtr->controlReg, ChannelAttn, 0); \
  102.     }
  103.  
  104. #define NET_IE_DELAY(condition) \
  105.     { \
  106.         register int i = (NET_IE_DELAY_CONST); \
  107.         while (i > 0 && !(condition)) { \
  108.             i--; \
  109.         } \
  110.         if (!(condition)) { \
  111.         printf("Delay %s:%d failed.\n", __FILE__, __LINE__); \
  112.         } \
  113.     }
  114.  
  115. #define    NET_IE_CHECK_SCB_CMD_ACCEPT(scbPtr) \
  116.     if (*(short *) &(scbPtr->cmdWord) != 0) { \
  117.     NetIECheckSCBCmdAccept(scbPtr); \
  118.     }
  119.  
  120. #define NET_IE_ADDR_FROM_SUN_ADDR(src, dest) { \
  121.     union { \
  122.         int     i; \
  123.         char    ch[4]; \
  124.     } addrTo, addrFrom; \
  125.     addrFrom.i = src; \
  126.     addrTo.ch[0] = addrFrom.ch[3]; \
  127.     addrTo.ch[1] = addrFrom.ch[2]; \
  128.     addrTo.ch[2] = addrFrom.ch[1]; \
  129.     addrTo.ch[3] = 0; \
  130.     dest = addrTo.i; \
  131. }
  132.  
  133. #define    NET_IE_ADDR_TO_SUN_ADDR(src, dest) { \
  134.     union { \
  135.     int     i; \
  136.     char    ch[4]; \
  137.     } addrTo, addrFrom; \
  138.     addrFrom.i = src; \
  139.     addrTo.ch[0] = 0; \
  140.     addrTo.ch[1] = addrFrom.ch[2]; \
  141.     addrTo.ch[2] = addrFrom.ch[1]; \
  142.     addrTo.ch[3] = addrFrom.ch[0]; \
  143.     dest = addrTo.i; \
  144. }
  145.  
  146. /*
  147.  * System configuration pointer.  Must be at 0xfffff6 in chip's address space.
  148.  */
  149.  
  150. typedef struct {
  151. #ifdef sun4
  152.     short padding;    /* Since structures can't start on a half-word boundry
  153.              * on the sun4, we start the structure on a word 
  154.              * boundry and include 2 bytes of padding.
  155.              */
  156. #endif /* sun4 */
  157.     char busWidth;    /* Bus width.  0 => 16 bits.  1 => 8 bits. */
  158.     char filler[5];    /* Unused. */
  159.     int     intSysConfPtr;    /* Address of intermediate system configuration 
  160.                pointer. */
  161. } NetIESysConfPtr;
  162.  
  163. /*
  164.  * Intermediate system configuration pointer.  This specifies the base of the 
  165.  * control blocks and the offset of the System Control Block (SCB).
  166.  */
  167.  
  168. typedef struct {
  169.     char  busy;            /* 1 if initialization in progress. */
  170.     char  filler;        /* Unused. */
  171.     short scbOffset;        /* Offset of the scb. */
  172.     int      base;            /* Base of all control blocks. */
  173. } NetIEIntSysConfPtr;
  174.  
  175. /*
  176.  * The system control block (SCB) status has the following format:
  177.  *
  178.  *typedef struct {
  179.  *    unsigned int             :1;      Must be zero   
  180.  *    unsigned int recvUnitStatus     :3;      Receive unit status   
  181.  *    unsigned int                 :4;      Must be zero   
  182.  *    unsigned int cmdDone        :1;      A command which has its interrupt
  183.  *                       bit set completed.   
  184.  *    unsigned int frameRecvd        :1;      A frame received interrupt has been
  185.  *                       given.   
  186.  *    unsigned int cmdUnitNotActive   :1;  The command unit has left the active
  187.  *                       state.   
  188.  *    unsigned int recvUnitNotReady   :1;  The command unit has left the ready
  189.                        state.   
  190.  *    unsigned int                    :1;      Must be zero.   
  191.  
  192.  *    unsigned int cmdUnitStatus        :3;   Command unit status.   
  193.  *} NetIESCBStatus;
  194.  */
  195. typedef unsigned short NetIESCBStatus[1];
  196.  
  197. #define RecvUnitStatus            0x0103
  198. #define CmdDone                   0x0801
  199. #define FrameRecvd                0x0901
  200. #define CmdUnitNotActive          0x0a01
  201. #define RecvUnitNotReady          0x0b01
  202. #define CmdUnitStatus             0x0d03
  203.  
  204. /*
  205.  * The system control block (SCB) command word has the following format:
  206.  *
  207.  * typedef struct {
  208.  *    unsigned int reset             :1;     Reset the chip.   
  209.  *    unsigned int recvUnitCmd        :3;    The command for the receive unit   
  210.  *    unsigned int              :4;     Unused.   
  211.  *
  212.  *    unsigned int ackCmdDone         :1;     Ack the command completed bit in
  213.  *                         the status word.   
  214.  *    unsigned int ackFrameRecvd      :1;     Ack the frame received bit in the
  215.  *                         the status word.   
  216.  *    unsigned int ackCmdUnitNotActive:1;     Ack that the command unit became
  217.  *                         not active.   
  218.  *    unsigned int ackRecvUnitNotReady:1;     Ack that the receive unit became
  219.  *                         not ready   
  220.  *    unsigned int             :1;     Unused.   
  221.  *    unsigned int cmdUnitCmd         :3;    The command for the command unit   
  222.  *} NetIESCBCommand;
  223.  */
  224. typedef unsigned short NetIESCBCommand[1];
  225.  
  226. #define Reset                     0x0001
  227. #define RecvUnitCmd               0x0103
  228. #define AckCmdDone                0x0801
  229. #define AckFrameRecvd             0x0901
  230. #define AckCmdUnitNotActive       0x0a01
  231. #define AckRecvUnitNotReady       0x0b01
  232. #define CmdUnitCmd                0x0d03
  233.  
  234.  
  235. /*
  236.  * Define the macros to Check and acknowledge the status of the chip.
  237.  *
  238.  * NET_IE_CHECK_STATUS    Extract the 4 status bits out of the scb status word.
  239.  * NET_IE_ACK        Set the bits in the scb command word that acknowledge 
  240.  *            the status bits in the scb status word.
  241.  * NET_IE_TRANSMITTED    Return true if a transit command finished.
  242.  * NET_IE_RECEIVED    Return true if a packet was received.
  243.  */
  244.  
  245. #define    NET_IE_CHECK_STATUS(scbStatus) ((*(short *) &(scbStatus)) & 0xF0)
  246. #define    NET_IE_ACK(scbCommand, status) ((*(short *) &(scbCommand)) |= status)
  247. #define    NET_IE_TRANSMITTED(status) status & 0xA0
  248. #define    NET_IE_RECEIVED(status) status & 0x50
  249.  
  250. /*
  251.  * The system control block.
  252.  */
  253.  
  254. typedef struct {
  255.     NetIESCBStatus    statusWord;
  256.     NetIESCBCommand    cmdWord;
  257.     short            cmdListOffset;
  258.     short            recvFrameAreaOffset;
  259.     short            crcErrors;        /* Count of crc errors. */
  260.     short        alignErrors;        /* Count of alignment errors. */
  261.     short        resourceErrors;        /* Count of correct incoming 
  262.                            packets discarded because
  263.                            of lack of buffer space */
  264.     short        overrunErrors;        /* Count of overrun packets */
  265. } NetIESCB;
  266.  
  267. /*
  268.  * Values for that status of the receive unit (recvUnitStatus).
  269.  */
  270.  
  271. #define NET_IE_RUS_IDLE                0
  272. #define NET_IE_RUS_SUSPENDED        1
  273. #define NET_IE_RUS_NO_RESOURCES        2
  274. #define NET_IE_RUS_READY            4
  275.  
  276. /*
  277.  * Values for that status of the command unit (cmdUnitStatus).
  278.  */
  279.  
  280. #define NET_IE_CUS_IDLE                0
  281. #define NET_IE_CUS_SUSPENDED        1
  282. #define NET_IE_CUS_ACTIVE            2
  283.  
  284. /*
  285.  * Values for the command unit command (cmdUnitCommand).
  286.  */
  287.  
  288. #define    NET_IE_CUC_NOP            0
  289. #define    NET_IE_CUC_START        1
  290. #define    NET_IE_CUC_RESUME        2
  291. #define    NET_IE_CUC_SUSPEND        3
  292. #define    NET_IE_CUC_ABORT        4
  293.  
  294. /*
  295.  * Values for the receive unit command (recvUnitCommand).
  296.  */
  297.  
  298. #define    NET_IE_RUC_NOP            0
  299. #define    NET_IE_RUC_START        1
  300. #define    NET_IE_RUC_RESUME        2
  301. #define    NET_IE_RUC_SUSPEND        3
  302. #define    NET_IE_RUC_ABORT          4
  303.  
  304. /*
  305.  * Generic command block
  306.  */
  307.  
  308. /* 
  309.  * The NetIECommandBlock has the following format:
  310.  *
  311.  * typedef struct {
  312.  *    unsigned int         :8;      Low order bits of status.  
  313.  *    unsigned int cmdDone    :1;      Command done.  
  314.  *    unsigned int cmdBusy    :1;      Command busy.  
  315.  *    unsigned int cmdOK    :1;      Command completed successfully.  
  316.  *    unsigned int cmdAborted    :1;      The command aborted.  
  317.  *    unsigned int        :4;      High order bits of status.  
  318.  *    unsigned int        :5;      Unused.  
  319.  *    unsigned int cmdNumber    :3;      Command number.  
  320.  *    unsigned int endOfList    :1;      The end of the command list.  
  321.  *    unsigned int suspend    :1;      Suspend when command completes.  
  322.  *    unsigned int interrupt    :1;      Interrupt when the command 
  323.  *                       completes.  
  324.  *    unsigned int        :5;      Unused.  
  325.  *   short       nextCmdBlock;      The offset of the next command 
  326.  *                       block.  
  327.  *} NetIECommandBlock;
  328.  */
  329.  
  330. typedef struct {
  331.     unsigned short    bits[2];    /* Control bits.  See below. */
  332.     short           nextCmdBlock;    /* The offset of the next command 
  333.                        block. */
  334. } NetIECommandBlock;
  335.  
  336. #define CmdDone                   0x0801
  337. #define CmdBusy                   0x0901
  338. #define CmdOK                     0x0a01
  339. #define CmdAborted                0x0b01
  340. #define CmdNumber                 0x1503
  341. #define EndOfList                 0x1801
  342. #define Suspend                   0x1901
  343. #define Interrupt                 0x1a01
  344.  
  345. /*
  346.  * Command block commands.
  347.  */
  348.  
  349. #define    NET_IE_NOP        0
  350. #define    NET_IE_IA_SETUP      1
  351. #define    NET_IE_CONFIG        2
  352. #define    NET_IE_MC_SETUP        3
  353. #define    NET_IE_TRANSMIT        4
  354. #define    NET_IE_TDR          5
  355. #define    NET_IE_DUMP         6
  356. #define    NET_IE_DIAGNOSE        7
  357.  
  358. /*
  359.  * The nop command block.
  360.  */
  361.  
  362. typedef struct {
  363.     NetIECommandBlock    cmdBlock;
  364. } NetIENOPCB;
  365.  
  366. /*
  367.  * The individual address setup command block.
  368.  */
  369.  
  370. typedef    struct {
  371.     NetIECommandBlock    cmdBlock;    /* The command block. */
  372.     Net_EtherAddress    etherAddress;    /* The ethernet address. */
  373. } NetIEIASetupCB;
  374.  
  375. /*
  376.  * The multicast address setup command block.
  377.  */
  378.  
  379. typedef    struct {
  380.     NetIECommandBlock    cmdBlock;    /* The command block. */
  381.     short        count;        /* Number of ethernet addresses. */
  382.     Net_EtherAddress    etherAddress;    /* The ethernet address. */
  383. } NetIEMASetupCB;
  384.  
  385. /*
  386.  * The bits of the configure command block have the following format:
  387.  *
  388.  * typedef struct {
  389.  *    NetIECommandBlock    cmdBlock;      The command block.  
  390.  *
  391.  *    unsigned int        :4;      Unused.  
  392.  *    unsigned int byteCount    :4;      Number of configuration bytes.  
  393.  *
  394.  *    unsigned int              :4;      Number of configuration bytes.  
  395.  *    unsigned int fifoLimit    :4;      The fifo limit.  
  396.  *
  397.  *    unsigned int saveBadFrames :1;      Save bad frames.  
  398.  *    unsigned int srdyArdy    :1;      srdy/ardy.  
  399.  *    unsigned int         :6;      Unused.  
  400.  *
  401.  *    unsigned int excLoopback    :1;      External loop back.  
  402.  *    unsigned int intLoopback    :1;      Internal loop back.  
  403.  *    unsigned int preamble    :2;      Preamble length code.  
  404.  *    unsigned int atLoc     :1;      Address and type fields are part  
  405.  *    unsigned int addrLen    :3;      The number of address bytes.  
  406.  *
  407.  *    unsigned int backOff    :1;      Backoff method.  
  408.  *    unsigned int expPrio    :3;      Exponential priority.  
  409.  *    unsigned int         :1;      Unused.  
  410.  *    unsigned int linPrio    :3;      Linear priority.  
  411.  *
  412.  *    unsigned int interFrameSpace:8;      Interframe spacing.  
  413.  *
  414.  *    unsigned int slotTimeLow    :8;      Low bits of slot time.  
  415.  *
  416.  *    unsigned int numRetries    :4;      Number of transmit retries.  
  417.  *    unsigned int         :1;      Unused.      
  418.  *    unsigned int slotTimeHigh    :3;      High bits of the slot time.  
  419.  *
  420.  *    unsigned int pad        :1;      Padding.  
  421.  *    unsigned int bitStuff    :1;      Hdlc bit stuffing.  
  422.  *    unsigned int crc16        :1;      CRC 16 bits or 32.  
  423.  *    unsigned int noCrcInsert    :1;      No crc insertion.  
  424.  *    unsigned int xmitOnNoCarr  :1;      Transmit even if no carrier sense.  
  425.  *    unsigned int manch    :1;      Manchester or NRZ encoding.  
  426.  *    unsigned int noBroadcast    :1;      Disable broadcasts.  
  427.  *    unsigned int promisc    :1;      Promiscuous mode.  
  428.  *
  429.  *    unsigned int collDetectSrc    :1;      Collision detect source.  
  430.  *    unsigned int cdFilter    :3;      Collision detect filter bits.  
  431.  *    unsigned int carrSenseSrc    :1;      Carrier sense source.  
  432.  *    unsigned int carrSenseFilter:3;    
  433.  *
  434.  *    unsigned int minFrameLength:8;      Minimum frame length.  
  435.  *
  436.  *    unsigned int        :8;      Unused.  
  437.  *} NetIEConfigureCB;
  438.  */
  439.  
  440. typedef struct {
  441.     NetIECommandBlock    cmdBlock;    /* The command block. */
  442.     unsigned short    bits[6];
  443. } NetIEConfigureCB;
  444.  
  445. #define ByteCount                 0x0404
  446. #define FifoLimit                 0x0c04
  447. #define SaveBadFrames             0x1001
  448. #define SrdyArdy                  0x1101
  449. #define ExcLoopback               0x1801
  450. #define IntLoopback               0x1901
  451. #define Preamble                  0x1a02
  452. #define AtLoc                     0x1c01
  453. #define AddrLen                   0x1d03
  454. #define BackOff                   0x2001
  455. #define ExpPrio                   0x2103
  456. #define LinPrio                   0x2503
  457. #define InterFrameSpace           0x2808
  458. #define SlotTimeLow               0x3008
  459. #define NumRetries                0x3804
  460. #define SlotTimeHigh              0x3d03
  461. #define Pad                       0x4001
  462. #define BitStuff                  0x4101
  463. #define Crc16                     0x4201
  464. #define NoCrcInsert               0x4301
  465. #define XmitOnNoCarr              0x4401
  466. #define Manch                     0x4501
  467. #define NoBroadcast               0x4601
  468. #define Promisc                   0x4701
  469. #define CollDetectSrc             0x4801
  470. #define CdFilter                  0x4903
  471. #define CarrSenseSrc              0x4c01
  472. #define CarrSenseFilter           0x4d03
  473. #define MinFrameLength            0x5008
  474.  
  475.  
  476. /*
  477.  * Transmit command block. 
  478.  */
  479.  
  480. typedef struct {
  481.     unsigned int bits[1];        /* See below. */
  482.     short      nextCmdBlock;        /* The offset of the next command 
  483.                        block */
  484.     short      bufDescOffset;    /* The offset of the buffer descriptor */
  485.     Net_EtherAddress  destEtherAddr;    /* The ethernet address of the 
  486.                        destination machine. */
  487.     short      type;            /* Ethernet packet type field. */
  488. } NetIETransmitCB;
  489.  
  490. /*
  491.  * The transmit command block has the following format:
  492.  *
  493.  * typedef struct {
  494.  *    unsigned int xmitDeferred    :1;      Transmission deferred.  
  495.  *    unsigned int heartBeat    :1;      Heart beat.  
  496.  *    unsigned int tooManyCollisions:1;      Too many transmit collisions.  
  497.  *    unsigned int         :1;      Unused.  
  498.  *    unsigned int numCollisions    :4;      The number of collisions 
  499.  *                       experienced  
  500.  *    unsigned int cmdDone    :1;      Command done.  
  501.  *    unsigned int cmdBusy    :1;      Command busy.  
  502.  *    unsigned int cmdOK        :1; Command completed successfully.  
  503.  *    unsigned int cmdAborted    :1;      The command aborted.  
  504.  *    unsigned int         :1;      Unused.  
  505.  *    unsigned int noCarrSense    :1;      No carrier sense.  
  506.  *    unsigned int noClearToSend    :1; Transmission unsuccessful because
  507.  *                       of loss of clear to send signal.  
  508.  *    unsigned int underRun    :1;       DMA underrun.  
  509.  *
  510.  *    unsigned int        :5;      Unused.  
  511.  *    unsigned int cmdNumber    :3;      Command number.  
  512.  *
  513.  *    unsigned int endOfList    :1;      The end of the command list.  
  514.  *    unsigned int suspend    :1;      Suspend when command completes.  
  515.  *    unsigned int interrupt    :1;      Interrupt when the command 
  516.  *    unsigned int         :5;      Unused.  
  517.  *
  518.  *    short      nextCmdBlock;          The offset of the next command 
  519.  *                       block  
  520.  *    short      bufDescOffset;      The offset of the buffer descriptor  
  521.  *    Net_EtherAddress  destEtherAddr;      The ethernet address of the 
  522.  *                       destination machine.  
  523.  *    short      type;              Ethernet packet type field.  
  524.  *} NetIETransmitCB;
  525.  */
  526.  
  527. #define XmitDeferred              0x0001
  528. #define HeartBeat                 0x0101
  529. #define TooManyCollisions         0x0201
  530. #define NumCollisions             0x0404
  531. #define CmdDone                   0x0801
  532. #define CmdBusy                   0x0901
  533. #define CmdOK                     0x0a01
  534. #define CmdAborted                0x0b01
  535. #define NoCarrSense               0x0d01
  536. #define NoClearToSend             0x0e01
  537. #define UnderRun                  0x0f01
  538. #define CmdNumber                 0x1503
  539. #define EndOfList                 0x1801
  540. #define Suspend                   0x1901
  541. #define Interrupt                 0x1a01
  542.  
  543.  
  544. /* 
  545.  * The transmit buffer descriptor.
  546.  */
  547.  
  548. typedef struct {
  549.     unsigned short bits[1];        /* See below. */
  550.     short    nextTBD;        /* Offset of the next transmit 
  551.                        buffer descriptor. */
  552.     int        bufAddr;        /* Address of buffer of data. */
  553. } NetIETransmitBufDesc;
  554.  
  555. /*
  556.  * The transmit buffer descriptor has the following format:
  557.  *
  558.  * typedef struct {
  559.  *    unsigned    int countLow    :8;      Low order 8 bits of count of bytes  
  560.  *    unsigned    int eof    :1;      Last buffer in the packet.  
  561.  *    unsigned    int        :1;      Unused.  
  562.  *    unsigned    int countHigh    :6;      High order 6 bits of the count.  
  563.  *
  564.  *    short    nextTBD;          Offset of the next transmit 
  565.  *                       buffer descriptor.  
  566.  *    int        bufAddr;          Address of buffer of data.  
  567.  *} NetIETransmitBufDesc;
  568.  */
  569.  
  570. #define CountLow                  0x0008
  571. #define Eof                       0x0801
  572. #define CountHigh                 0x0a06
  573.  
  574. /*
  575.  * The receive frame descriptor.
  576.  */
  577.  
  578. typedef struct NetIERecvFrameDesc {
  579.     unsigned int bits[1];        /* See below. */
  580.     short nextRFD;            /* Next receive frame descriptor. */
  581.     short recvBufferDesc;        /* Offset of the first receive buffer
  582.                        descriptor. */
  583.  
  584.     Net_EtherAddress destAddr;        /* Destination ethernet address. */
  585.     Net_EtherAddress srcAddr;        /* Source ethernet address. */
  586.     short      type;            /* Ethernet packet type. */
  587.     volatile struct NetIERecvFrameDesc *realNextRFD; /* The SUN address of 
  588.                                         the next receive frame descriptor. */
  589. } NetIERecvFrameDesc;
  590.  
  591. /*
  592.  * The receive frame descriptor has the following format:
  593.  *
  594.  * typedef struct NetIERecvFrameDesc {
  595.  *    unsigned int shortFrame    :1;      Was a short frame.  
  596.  *    unsigned int noEOF    :1;      No EOF (bitstuffing mode only).  
  597.  *    unsigned int         :6;      Unused.  
  598.  *
  599.  *    unsigned int done        :1;      Frame completely stored.  
  600.  *    unsigned int busy        :1;      Busy storing frame.  
  601.  *    unsigned int ok        :1;      Frame received OK  
  602.  *    unsigned int         :1;      Unused.  
  603.  *    unsigned int crcError    :1;      Received packet had a crc error  
  604.  *    unsigned int alignError    :1;      Received packet had an alignment * 
  605.  *                       error  
  606.  *    unsigned int outOfBufs    :1;      Receive unit ran out of memory  
  607.  *    unsigned int overrun    :1;      DMA overrun.  
  608.  *
  609.  *    unsigned int         :8;      Unused.  
  610.  *
  611.  *    unsigned int endOfList    :1;      End of list.  
  612.  *    unsigned int suspend    :1;      Suspend when done receiving.  
  613.  *    unsigned int         :6;      Unused.  
  614.  *
  615.  *    short nextRFD;              Next receive frame descriptor.  
  616.  *    short recvBufferDesc;          Offset of the first receive buffer
  617.  *                       descriptor.  
  618.  *
  619.  *    Net_EtherAddress destAddr;      Destination ethernet address.  
  620.  *    Net_EtherAddress srcAddr;          Source ethernet address.  
  621.  *    short      type;              Ethernet packet type.  
  622.  *    volatile struct NetIERecvFrameDesc *realNextRFD;   The SUN address of 
  623.  *                                        the next receive frame descriptor.  
  624.  *} NetIERecvFrameDesc;
  625.  */
  626.  
  627. #define ShortFrame                0x0001
  628. #define NoEOF                     0x0101
  629. #define Done                      0x0801
  630. #define Busy                      0x0901
  631. #define Ok                        0x0a01
  632. #define CrcError                  0x0c01
  633. #define AlignError                0x0d01
  634. #define OutOfBufs                 0x0e01
  635. #define Overrun                   0x0f01
  636. #define EndOfList                 0x1801
  637. #define Suspend                   0x1901
  638.  
  639. /*
  640.  * Receive buffer descriptor.
  641.  */
  642. typedef struct NetIERecvBufDesc {
  643.     unsigned short bits1[1];        /* See below. */
  644.  
  645.     short nextRBD;            /* Next receive buffer descriptor. */
  646.     int      bufAddr;            /* The address of the buffer that
  647.                        this descriptor puts its data. */
  648.  
  649.     unsigned short bits2[1];        /* See below. */
  650.     Address    realBufAddr;        /* The SUN address of the buffer 
  651.                        where this descriptor puts its data*/
  652.     volatile struct NetIERecvBufDesc *realNextRBD; /* The 6800 Address of the
  653.                                             next receive buffer descriptor. */
  654. } NetIERecvBufDesc;
  655.  
  656. /*
  657.  * The receive buffer descriptor has the following format:
  658.  *
  659.  * typedef struct NetIERecvBufDesc {
  660.  *    unsigned int countLow    :8;      Low order bits of the count of bytes
  661.  *                       in this buffer.  
  662.  *    unsigned int eof        :1;      Last buffer for this packet.  
  663.  *    unsigned int countValid    :1;      The value in the count field is 
  664.  *                       valid.  
  665.  *    unsigned int countHigh    :6;      High order bits of the count.  
  666.  *
  667.  *    short nextRBD;              Next receive buffer descriptor.  
  668.  *    int      bufAddr;          The address of the buffer that
  669.  *                       this descriptor puts its data.  
  670.  *
  671.  *    unsigned int bufSizeLow    :8;      Low order bits of amount of bytes
  672.  *                       this buffer is capable of holding  
  673.  *    unsigned int endOfList    :1;      This is the end of the RBD list.  
  674.  *    unsigned int        :1;      Unused.  
  675.  *    unsigned int bufSizeHigh    :6;      High order 6 bits of the buffer 
  676.  *                       size.  
  677.  *    Address    realBufAddr;          The SUN address of the buffer 
  678.  *                       where this descriptor puts its data 
  679.  *    volatile struct NetIERecvBufDesc *realNextRBD;   The 6800 Address of the
  680.  *                                            next receive buffer descriptor.  
  681.  *} NetIERecvBufDesc;
  682.  */
  683.  
  684. #define CountLow                  0x0008
  685. #define Eof                       0x0801
  686. #define CountValid                0x0901
  687. #define CountHigh                 0x0a06
  688.  
  689. #define BufSizeLow                0x0008
  690. #define RBDEndOfList              0x0801
  691. #define BufSizeHigh               0x0a06
  692.  
  693. /*
  694.  * The intel ethernet register.
  695.  */
  696.  
  697. typedef unsigned char NetIEControlRegister;
  698.  
  699. /*
  700.  * The intel ethernet register has the following format:
  701.  *
  702.  * typedef struct {
  703.  *    unsigned int noReset    :1;      R/W: 0 => Ethernet reset, 
  704.  *                        1 => Normal.  
  705.  *    unsigned int noLoopback    :1;      R/W: 0 => Loopback, 
  706.  *                        1 => Normal.  
  707.  *    unsigned int channelAttn    :1;      R/W: Channel Attention.  
  708.  *    unsigned int intrEnable    :1;      R/W: Interrupt enable.  
  709.  *    unsigned int         :2;      Reserved.  
  710.  *    unsigned int busError    :1;      R/O: DMA bus error.  
  711.  *    unsigned int intrPending    :1;      R/O: Got an interrupt request.  
  712.  *} NetIEControlRegister;
  713.  */
  714.  
  715. #define NoReset                   0x0001
  716. #define NoLoopback                0x0101
  717. #define ChannelAttn               0x0201
  718. #define IntrEnable                0x0301
  719. #define BusError                  0x0601
  720. #define IntrPending               0x0701
  721.  
  722. /*
  723.  * Structure to hold all state information associated with one of these
  724.  * chips.
  725.  */
  726.  
  727. typedef struct {
  728.     unsigned int    memBase;    /* Address of control block memory. */
  729.     volatile NetIESysConfPtr *sysConfPtr;
  730.                                         /* Where the system configuration
  731.                        pointer is at. */
  732.     volatile NetIEIntSysConfPtr    *intSysConfPtr;
  733.                                         /* Where the intermediate system
  734.                        configuration pointer is at. */
  735.     volatile NetIESCB    *scbPtr;    /* Pointer to system control block. */
  736.     volatile NetIECommandBlock *cmdBlockPtr;/* Head of command block list */
  737.     volatile NetIERecvFrameDesc    *recvFrDscHeadPtr; /* Head of receive frame
  738.                                             descriptor list. */
  739.     volatile NetIERecvFrameDesc    *recvFrDscTailPtr; /* Tail of receive frame
  740.                                             descriptor list. */
  741.     volatile NetIERecvBufDesc *recvBufDscHeadPtr; /* Head of receive buffer
  742.                                             descriptor list. */
  743.     volatile NetIERecvBufDesc *recvBufDscTailPtr; /* Tail of receive buffer
  744.                                             descriptor list. */
  745.     List_Links        *xmitList;    /* Pointer to the front of the list of
  746.                        packets to be transmited. */
  747.     List_Links          *xmitFreeList;    /* Pointer to a list of unused 
  748.                        transmission queue elements. */
  749.     List_Links        xmitListHdr;    /* The transmit list. */
  750.     List_Links        xmitFreeListHdr;/* The unused elements. */
  751.     volatile NetIETransmitCB *xmitCBPtr; /* Pointer to the single command block
  752.                        for transmitting packets. */
  753.     Boolean        transmitting;    /* Set if are currently transmitting a
  754.                        packet. */
  755.     Boolean        running;    /* Is the chip currently active. */
  756.     volatile NetIEControlRegister *controlReg;/* The onboard device register.*/
  757.     Net_EtherAddress    etherAddress;    /* The ethernet address in reverse
  758.                        byte order. */
  759.     char        *netIEXmitTempBuffer;    /* Buffer for pieces of a 
  760.                          * packet that are too small
  761.                          * or misaligned. */
  762.     volatile NetIETransmitBufDesc *xmitBufAddr;    /* The address of the array 
  763.                          * of buffer descriptor 
  764.                          * headers. */
  765.     Net_ScatterGather     *curScatGathPtr;  /* Pointer to scatter gather element 
  766.                        * for current packet being sent. */
  767.     Net_Interface    *interPtr;    /* Pointer back to network interface. */
  768.     Net_EtherStats    stats;        /* Performance statistics. */
  769.     Address        netIERecvBuffers[NET_IE_NUM_RECV_BUFFERS]; /* Buffers.*/
  770.     char                loopBackBuffer[NET_ETHER_MAX_BYTES]; /* Buffer for the
  771.                           * loopback address. */
  772. } NetIEState;
  773.  
  774. /*
  775.  * XMIT_TEMP_BUFSIZE limits how big a thing can
  776.  * be and start on an odd address.
  777.  */
  778. #define XMIT_TEMP_BUFSIZE    (NET_ETHER_MAX_BYTES + 2)
  779.  
  780. /*
  781.  * Define the minimum size allowed for a piece of a transmitted packet.
  782.  * There is a minimum size because the Intel chip has problems if the pieces
  783.  * are too small.
  784.  */
  785. #define MIN_XMIT_BUFFER_SIZE    12
  786.  
  787. /*
  788.  * Buffers for output.
  789.  */
  790. extern    char    *netIEXmitFiller;
  791.  
  792. /*
  793.  * General routines.
  794.  */
  795.  
  796. extern ReturnStatus NetIEInit _ARGS_((Net_Interface *interPtr));
  797. extern ReturnStatus NetIEOutput _ARGS_((Net_Interface *interPtr, 
  798.         Address hdrPtr, Net_ScatterGather *scatterGatherPtr,
  799.         int scatterGatherLength, Boolean rpc, ReturnStatus *statusPtr));
  800. extern void NetIEIntr _ARGS_((Net_Interface *interPtr, Boolean polling));
  801. extern ReturnStatus NetIEIOControl _ARGS_((Net_Interface *interPtr, 
  802.             Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
  803. extern void NetIERestart _ARGS_((Net_Interface *interPtr));
  804. extern void NetIEReset _ARGS_((Net_Interface *interPtr));
  805. extern ReturnStatus NetIEGetStats _ARGS_((Net_Interface *interPtr, 
  806.             Net_Stats *statPtr));
  807.  
  808. /*
  809.  * Routines for transmitting.
  810.  */
  811.  
  812. extern void NetIEXmitInit _ARGS_((NetIEState *statePtr));
  813. extern void NetIEXmitDone _ARGS_((NetIEState *statePtr));
  814. extern void NetIEXmitDrop _ARGS_((NetIEState *statePtr));
  815.  
  816. /*
  817.  * Routines for the command unit.
  818.  */
  819.  
  820. extern void NetIECheckSCBCmdAccept _ARGS_((volatile NetIESCB *scbPtr));
  821. extern void NetIEExecCommand _ARGS_((register volatile NetIECommandBlock *cmdPtr, NetIEState *statePtr));
  822.  
  823. /*
  824.  * Routines for the receive unit.
  825.  */
  826.  
  827. extern void NetIERecvUnitInit _ARGS_((NetIEState *statePtr));
  828. extern void NetIERecvProcess _ARGS_((Boolean dropPackets, NetIEState *statePtr));
  829.  
  830. /*
  831.  * Memory routines.
  832.  */
  833.  
  834. extern void NetIEMemInit _ARGS_((NetIEState *statePtr));
  835. extern Address NetIEMemAlloc _ARGS_((NetIEState *statePtr));
  836.  
  837. /*
  838.  * Routines to convert to addresses and offsets.
  839.  */
  840.  
  841. extern int NetIEAddrFromSUNAddr _ARGS_((int addr));
  842. extern int NetIEAddrToSUNAddr _ARGS_((int addr));
  843. extern int NetIEOffsetFromSUNAddr _ARGS_((int addr, NetIEState *statePtr));
  844. extern int NetIEOffsetToSUNAddr _ARGS_((int offset, NetIEState *statePtr));
  845. extern int NetIEShortSwap _ARGS_((int num));
  846.  
  847. extern void NetIEStatePrint _ARGS_((NetIEState *statePtr));
  848. extern void NetIEIntSysConfPtrPrint _ARGS_((volatile 
  849.         NetIEIntSysConfPtr *confPtr));
  850. extern void NetIESCBPrint _ARGS_((volatile NetIESCB *scbPtr));
  851.  
  852. #endif /* _NETIEINT */
  853.